package com.lovo.homework7_8GameOfRockPaperScissors;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Player extends Role{
    private String name="玩家";

    public Player(){
        super();
        setName(name);
    }
    public static int numbers;
    public void generate(){
        Scanner scanner = new Scanner(System.in);
        setNumber(numbers);
        System.out.println("请出招，0代表石头，1代表布，2代表剪刀");
        for (int i = 1; i < 2; i++) {
            try {

                numbers = scanner.nextInt();
                setNumber(numbers);
                if (numbers < 0 || numbers > 2) {
                    System.out.println("错误输入，请输入数字0、1、2");
                    i--;
                    continue;
                }

            }catch (InputMismatchException e){
                System.out.println("错误输入，请输入数字0、1、2");
                scanner.next();
                i--;
            }
        }
    }
}
